<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>用户注册</title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="../assets/vendors/feather/feather.css">
    <link rel="stylesheet" href="../assets/vendors/mdi/css/materialdesignicons.min.css">
    <link rel="stylesheet" href="../assets/vendors/ti-icons/css/themify-icons.css">
    <link rel="stylesheet" href="../assets/vendors/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../assets/vendors/typicons/typicons.css">
    <link rel="stylesheet" href="../assets/vendors/simple-line-icons/css/simple-line-icons.css">
    <link rel="stylesheet" href="../assets/vendors/css/vendor.bundle.base.css">
    <link rel="stylesheet" href="../assets/vendors/bootstrap-datepicker/bootstrap-datepicker.min.css">
    <!-- endinject -->
    <!-- Plugin css for this page -->
    <!-- End plugin css for this page -->
    <!-- inject:css -->
    <link rel="stylesheet" href="../assets/css/style.css">
    <!-- endinject -->
    <link rel="shortcut icon" href="../assets/images/favicon.png" />
  </head>
  <body>
    <div class="container-scroller">
      <div class="container-fluid page-body-wrapper full-page-wrapper">
        <div class="content-wrapper d-flex align-items-center auth px-0">
          <div class="row w-100 mx-0">
            <div class="col-lg-5 mx-auto">
              <div class="auth-form-light text-left py-5 px-4 px-sm-5">
                <div class="brand-logo">
                  <img src="../assets/images/logo.svg" alt="logo">
                </div>
<!--                <h4>New here?</h4>-->
<!--                <h6 class="fw-light">Signing up is easy. It only takes a few steps</h6>-->
                <form class="pt-3" action="../register.php" method="post" onsubmit="return validateForm();">
                  <div class="form-group">
                    <label for="username">用户名</label>
                    <input type="text" class="form-control" name="username" placeholder="Username">
                  </div>
                  <div class="form-group">
                    <label for="email">电子邮箱</label>
                    <input type="email" class="form-control" name="email" placeholder="Email">
                  </div>
                  <div class="form-group">
                    <label for="Password">密码</label>
                    <input type="password" class="form-control" name="password" placeholder="Password">
                  </div>
                  <div class="form-group">
                    <label for="ConfirmPassword">确认密码</label>
                    <input type="password" class="form-control" name="confirm_password" placeholder="Password">
                  </div>
                  <div class="form-group">
                    <label for="Address">地址</label>
                    <input type="text" class="form-control" name="address" placeholder="Address">
                  </div>
                  <div class="mb-4">
                    <div class="form-check">
                      <label class="form-check-label text-muted">
                        <input type="checkbox" class="form-check-input" id="termsCheckbox"> 我同意所有条款 </label>
                    </div>
                  </div>
                  <div class="mt-3 d-grid gap-2">
                    <button type="submit" class="btn btn-block btn-primary btn-lg fw-medium auth-form-btn" >注册</button>
                  </div>
                  <div class="text-center mt-4 fw-light"> 已有账号? <a href="login-page.php" class="text-primary">登录</a>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
        <!-- content-wrapper ends -->
      </div>
      <!-- page-body-wrapper ends -->
    </div>
    <!-- container-scroller -->
    <!-- plugins:js -->
    <script src="../assets/vendors/js/vendor.bundle.base.js"></script>
    <script src="../assets/vendors/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <!-- endinject -->
    <script>
        function validateForm() {
            var uname = document.forms[0].username.value;
            var email = document.forms[0].email.value;
            var pass = document.forms[0].password.value;
            var confirm_password = document.forms[0].confirm_password.value;
            var address = document.forms[0].address.value;
            var checkbox = document.getElementById("termsCheckbox");

            // 校验输入
            if (!uname || !email || !pass || !address) {
                alert("所有字段都必须填写！");
                return false; // 阻止表单提交
            }

            if (!/^[a-zA-Z]/.test(uname)) {
                alert("用户名首字母必须为字母。");
                return false; // 阻止表单提交
            }

            if (pass.length < 6 || pass.length > 8) {
                alert("密码长度应为6到8个字符。");
                return false; // 阻止表单提交
            }

            if (pass !== confirm_password) {
                alert("密码不一致。");
                return false; // 阻止表单提交
            }

            if (!checkbox.checked) {
                alert("请勾选同意条款的复选框才能提交注册。");
                return false; // 阻止表单提交
            }

            return true; // 允许表单提交
        }
    </script>
    <!-- Plugin js for this page -->
    <!-- End plugin js for this page -->
    <!-- inject:js -->
    <script src="../assets/js/off-canvas.js"></script>
    <script src="../assets/js/template.js"></script>
    <script src="../assets/js/settings.js"></script>
    <script src="../assets/js/hoverable-collapse.js"></script>
    <script src="../assets/js/todolist.js"></script>
    <!-- endinject -->
  </body>
</html>